07. Lesson 1 Exercise
Lesson 1 Exercise
Overview
ND213 C04 L01 C1.7-Atom1a SC
Code Walkthrough
Note: we recommend playing the video below full-screen so you will be able to see the code.
C1-7-A2-SC
Project Tasks
-
Task L1.1 : In the base class
TrafficObject, set up a thread barrier in its destructor that ensures
that all the thread objects in the member vector_threadsare joined. -
Task L1.2 : In the
Vehicleclass, start a thread with the member functiondriveand the
objectthisas the launch parameters. Also, add the created thread into the_threadvector of
the parent class. -
Task L1.3 : Vary the number of simulated vehicles in
mainand use the top function on the terminal
or the task manager of your system to observe the number of threads used by the simulation.
You can find these tasks in the
project_tasks.txt
within the workspace as well.
Build Instructions
To run this code using a Udacity workspace, you will need to use the virtual desktop . In the desktop you can use Terminator or the terminal in Visual Studio Code.
Once in the virtual desktop, to compile and run the code, create a
build
directory and use
cmake
and
make
as follows:
root@a9ad274128c4:/home/workspace/L1_Project# mkdir build
root@a9ad274128c4:/home/workspace/L1_Project# cd build
root@a9ad274128c4:/home/workspace/L1_Project/build# cmake ..
root@a9ad274128c4:/home/workspace/L1_Project/build# make
root@a9ad274128c4:/home/workspace/L1_Project/build# ./traffic_simulation
Workspace
This section contains either a workspace (it can be a Jupyter Notebook workspace or an online code editor work space, etc.) and it cannot be automatically downloaded to be generated here. Please access the classroom with your account and manually download the workspace to your local machine. Note that for some courses, Udacity upload the workspace files onto https://github.com/udacity , so you may be able to download them there.
Workspace Information:
- Default file path:
- Workspace type: react
- Opened files (when workspace is loaded): n/a
-
userCode:
export CXX=g++-7